#include "Thread.h"

CThread::CThread()  : m_Running(false)
					, m_thread(0){

}

CThread::~CThread(){
	if(m_thread)
		delete m_thread;
}

void CThread::start(){
	m_thread = new pthread_t;
	DWORD thread_id;
	*m_thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)launch, this, 0, &thread_id);
	m_Running = true;
}

void CThread::launch(void * n_thread) {
	CThread *thread = (CThread*)n_thread;
	thread->execute();
	return;
}

bool CThread::is_running(){
	return m_Running;
}

void CThread::suspend(){
	TerminateThread(*m_thread, 0);
}